package package_20220905;

import java.util.*;

public class LowArrayMain {
	public static void main(String[] args) {
		//long[] arr = new long[8];
		//int nItem = 0;
		LowArray la = new LowArray();
		//1. insert item
		long data = 567;
		//arr[nItem++] = data;
		la.insertItem(data);
		data = 789;
		//arr[nItem++] = data;
		la.insertItem(data);
		//...
		data = 123;
		//arr[nItem++] = data;
		la.insertItem(data);
		data = 555;
		//arr[nItem++] = data;
		la.insertItem(data);
		
		la.display();
		
		// 2. find 123
		long key = 123;
		int res = la.find(key);
		if(res == -1) {
			System.out.println("该数组中没有要找的元素!");
		}else {
			String msg = String.format("Found %d in %d", key, res);
			System.out.println(msg);
		}
		
		// 3. delete 789
		Scanner scanner = new Scanner(System.in);
		while(true) {
			System.out.print("请输入要删除的值:");
			key = scanner.nextLong();
			if(la.find(key) != -1) {
				la.delect(key);
				System.out.println("After delete" + key);
				break;
			}
			System.out.println("数组中不存在该元素, 请重新输入!");
		}
		
		la.display();	
	}
}

